import { SerpAPILoader } from "@langchain/community/document_loaders/web/serpapi";
import { CheerioWebBaseLoader } from "@langchain/community/document_loaders/web/cheerio";

const apiKey =
  "3a816e810e17b00076d3741542bfdcbe0b655abc820b79164eaf2397e5712641";

const q = "什么是Copilot？";

const loader = new SerpAPILoader({
  q,
  apiKey,
});

const result = await loader.load();

const jsonResult = JSON.parse(result[1].pageContent);

const link = jsonResult.link;

// console.log(link)

const webLoader = new CheerioWebBaseLoader(link);

const webContent = await webLoader.load();

console.log(webContent);
